<template>
  <view class="hotel-share-card">
    <view class="content-view">
      <block v-for="(content, index) in info.args.cardContent" :key="index">
        <view
          class="flex"
          @click="gotoHotelDetails()"
        >
          <image
            :src="content.mainPictureUrl"
            class="main-img"
            mode="aspectFill"
          ></image>
          <view style="flex: 1">
            <view
              class="title-view"
            >
              <text>{{ content.name }}</text>
            </view>
            <view
              class="font-weight-normal"
            >
              <img
                class="icon"
                :src="content.tagIcon"
                mode="aspectFill"
              />
              <text class="single-line-text">{{ content.tag }}</text>
            </view>
            <view class="font-weight-normal">
              <img
                class="icon"
                :src="content.priceIcon"
                mode="aspectFill"
              />
                {{ content.price }}
            </view>
            <view class="font-weight-normal">
              <img
                class="icon"
                :src="content.addressIcon"
                mode="aspectFill"
              />
              <text class="single-line-text">{{ content.address }}</text>
            </view>
            <view class="left-item like">
              <view class="mark-box">
                <view style="display: flex; flex-wrap: wrap; flex: 1">
                  <block
                    v-for="(star, sindex) in Math.floor(content.hotelScore)"
                    :key="sindex"
                  >
                    <img
                      class="star-icon"
                      :src="content.starSelectIcon"
                      alt=""
                      srcset=""
                    />
                  </block>
                  <img
                    class="star-icon"
                    v-if="!isInteger(content.hotelScore)"
                    :src="content.starSelectHalfIcon"
                  />
                </view>
                <view class="star-pf">{{ content.hotelScore }}分</view>
              </view>
              <view class="evaluate">推荐 {{ content.hotelCommentCnt }}</view>
            </view>
          </view>
        </view>
      </block>
    </view>
    <block v-if="info.args.cardBtn && info.args.cardBtn.length > 0">
      <view
        class="btn-view"
        v-for="(btn, index) in info.args.cardBtn"
        :key="index"
        :data-spmCntSuffix="'ChatAiPage.aiHotelShareCard@1.more'"
        :data-custom="1"
        :data-spm="1"
        @click="gotoHotelDetails()"
      >{{ btn.text }}</view>
    </block>
  </view>
</template>

<script>
export default {
  components: {},
  props: {
    info: {
      type: Object,
    },
  },
  data() {
    return {
      marketDetailData: "",
    };
  },
  mounted() {},
  methods: {
    async gotoHotelDetails() {
      const info = this.info.args.cardContent[0]
      console.log(info);
      this.$navTo(
        `/packageAI/pages/aiHotelInfo/aiHotelInfo?productId=${info.productId}&rpId=${info.rpId}&stdId=${info.stdId}&isFromChat=true`,
        {},
        "navigateTo"
      );
    },
    isInteger(number) {
      return Number.isInteger(number);
    },
  },
};
</script>

<style lang="scss" scoped>
@import "../css/common.scss";
</style>
